import { defineStore } from "pinia";
import { Names } from "./store-name";
import { getDashboard } from "@/api/login";
import { useRequest } from "alova";
import type { TDashboard } from "@/typing/base";

const useDashboard = defineStore(Names.DASHBOARD, {
  state: () => {
    return {
      dashboardData: <TDashboard>{},
      dashboardLoading: false
    }
  },
  getters: {

  },
  actions: {
    getDashboard() {
      const { onSuccess, loading } = useRequest(getDashboard())
      onSuccess(({ data }: any) => {
        this.dashboardLoading = loading.value
        this.dashboardData = data.data
      })
    }
  }
})

export default useDashboard
